<?php
/**
* Author	: TRUONG KIM PHUNG
* Class		: Event
* Description
	* Manage Event
	* Get
	* Add
	* Update
	* Delete
* Contact	:
	- Email : truongkimphung1982@gmail.com
	- Y!	: truongkimphung1982
	- Skype	: truongkimphung1982
**/
class Event extends Ecore_Db {
	var $cache;
	var $clear;
	public function __construct() {
		
	}	
	/**
	 * GET INFORMATION EVENT BY ID
	 * @PARAM
			- $intEventId
	 * @RESULT
			- Array | NULL
	 */
	public function get($intEventId) {
		try {
			$this->prepare('call educations_get(?)');
			$this->bindParam(1 , $intEventId	, PDO::PARAM_INT, 11);			
			$arrResult 	= $this->fetchAll();				
			return isset($arrResult[0]) ? $arrResult[0] : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Event::get - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET TOP EVENT 
	 * @PARAM
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getTop($intLimit=0) {
		try {
			$this->prepare('call events_top(?)');
			$this->bindParam(1 , $intLimit	, PDO::PARAM_INT, 11);		
			$arrResult 	= $this->fetchAll();
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Event::getTop - ' . $e->getMessage());
			
		}
	}
	public function getAll($intLanguage, $intType, $intCategoryId, $intOffset, $intLimit, &$intTotal=0) {		
		try {						
			$this->prepare('call events_getall(?,?,?,?,?)');
			$this->bindParam(1 , $intLanguage	, PDO::PARAM_INT, 4);		
			$this->bindParam(2 , $intType		, PDO::PARAM_INT, 4);		
			$this->bindParam(3 , $intCategoryId	, PDO::PARAM_INT, 11);		
			$this->bindParam(4 , $intOffset		, PDO::PARAM_INT, 11);		
			$this->bindParam(5 , $intLimit		, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();				
			$intTotal	= isset($arrResult[0]['foundRows']) ? $arrResult[0]['foundRows'] : -1;
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Event::getAll - ' . $e->getMessage());
			
		}
	}
}